using System.Windows.Forms;
using HogoLogic.HgFileSystem;

namespace FileSystemView
{
	class DirectoryTreeNodeVisualizer
	{
		public TreeNode MakeTreeNode(HgDirectoryInfo info)
		{
			TreeNode result = new TreeNode();
			result.Text = info.Name;
			result.Tag = info;
			foreach (HgDirectoryInfo subDirectory in info.GetDirectories())
			{
				result.Nodes.Add(MakeTreeNode(subDirectory));
			}

			return result;
		}

		public HgDirectoryInfo GetDirectoryForTreeNode(TreeNode node)
		{
			return node != null ? node.Tag as HgDirectoryInfo : null;
		}
	}
}
